package com.skyline.spot.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.skyline.base.dao.impl.BaseDaoImpl;
import com.skyline.base.type.RatyObjType;
import com.skyline.spot.dao.RatyDao;
import com.skyline.spot.mapper.RatyMapper;
import com.skyline.spot.model.Raty;

@Repository("ratyDao")
public class RatyDaoImpl extends BaseDaoImpl implements RatyDao {
	@Value("${RatyDao.insert}")
	private String ratySQL;
	@Value("${RatyDao.queryByObjIdAndUserId}")
	private String isRatySQL;

	@Override
	public void raty(Long objId, RatyObjType type, Long userId, Integer ratyStar) {
		// TODO Auto-generated method stub
		jdbcTemplate.update(ratySQL, objId, type.toString(), userId, ratyStar);

	}

	@Override
	public boolean isRaty(Long objId, Long userId) {
		// TODO Auto-generated method stub
		List<Raty> list = jdbcTemplate.query(isRatySQL, RatyMapper.getMapper(),
				objId, userId);
		if (list.isEmpty())
			return false;
		else
			return true;
	}

}
